<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>学习vue</title>
    <!-- 引入vue -->
    <script src="../js/vue.js"></script>
</head>
<body>
    <div id="root">
        <!-- 响应点击 -->
        <button v-on:click="showInfo1">点我1</button>
        <!-- 简写成@click -->
        <button @click="showInfo2">点我2</button>
        <!-- $event就是会被替换成event -->
        <button @click="showInfo3(666,$event)">点我3</button>
    </div>
    <script>
        Vue.config.productionTip = false
        const vm = new Vue({
            el:'#root',
            data(){
                return{
                    name:'zzz1',
                }
            },
            methods:{
                showInfo1(event){
                    console.log(event.target.innerText)
                    //这里的this是vm
                    console.log(this)
                },
                showInfo2:(event)=>{
                    console.log(event.target.innerText)
                    //这里的this是windows
                    //箭头函数会向外查找上一级
                    console.log(this)
                },
                showInfo3(number,event){
                    console.log(number)
                    console.log(event.target.innerText)
                    //这里的this是windows
                    //箭头函数会向外查找上一级
                    console.log(this)
                }
            }
        })
    </script>    
</body>
</html>